﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MySoftLab.DapFlashCore.Probes.DapAccess
{
    public abstract class DAPAccessIntf
    {
        public class TransferFaultError : Exception
        {

        }

        public class TransferTimeoutError : Exception
        {

        }

        public class TransferError : Exception
        {
            public TransferError(string message) : base(message)
            {

            }

            public TransferError()
            {

            }
        }

        public class DeviceError : Exception
        {
            public DeviceError()
            {

            }

            public DeviceError(string message) : base(message)
            {

            }
        }

        public class CommandError : DeviceError
        {
            public CommandError()
            {

            }

            public CommandError(string message) : base(message)
            {

            }
        }

        public enum PORT
        {
            SWD = 1,
            DEFAULT = SWD,
            JTAG = 2
        }

        public enum REG
        {
            DP_0x0 = 0,
            DP_0x4 = 1,
            DP_0x8 = 2,
            DP_0xC = 3,
            AP_0x0 = 4,
            AP_0x4 = 5,
            AP_0x8 = 6,
            AP_0xC = 7
        }

        public enum ID
        {
            VENDOR = 1,
            PRODUCT = 2,
            SER_NUM = 3,
            CMSIS_DAP_PROTOCOL_VERSION = 4,
            DEVICE_VENDOR = 5,
            DEVICE_NAME = 6,
            BOARD_VENDOR = 7,
            BOARD_NAME = 8,
            PRODUCT_FW_VERSION = 9,
            CAPABILITIES = 0xf0,
            TEST_DOMAIN_TIMER = 0xf1,
            UART_RECEIVE_BUFFER_SIZE = 0xfb,
            UART_TRANSMIT_BUFFER_SIZE = 0xfc,
            SWO_BUFFER_SIZE = 0xfd,
            MAX_PACKET_COUNT = 0xfe,
            MAX_PACKET_SIZE = 0xff
        }

        public virtual (int, int, int) ProtocolVersion
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public virtual string FirmwareVersion
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public abstract string VendorName
        {
            get;
        }

        public abstract string ProductName
        {
            get;
        }

        public abstract (uint, uint) VidPid
        {
            get;
        }

        public virtual Tuple<string, string> BoardNames
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public virtual Tuple<string, string> TargetNames
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public virtual bool HasSwdSequence
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public virtual bool SupportsBoardAndTargetNames
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public virtual bool IsOpen
        {
            get
            {
                throw new NotImplementedException();
            }
        }

        public virtual void Open()
        {
            throw new NotImplementedException();
        }

        public virtual void Close()
        {
            throw new NotImplementedException();
        }

        public virtual string GetUniqueId()
        {
            throw new NotImplementedException();
        }

        public virtual void Identify(string item)
        {
            throw new NotImplementedException();
        }

        public virtual void Connect(PORT? port)
        {
            throw new NotImplementedException();
        }

        public virtual void ConfigureSwd(uint turnAround = 1, bool alwaysSendDataPhase = false)
        {
            throw new NotImplementedException();
        }

        public virtual void ConfigureJtag(int devicesIrlen)
        {
            throw new NotImplementedException();
        }

        public virtual void SwjSequence(int length, int bits)
        {
            throw new NotImplementedException();
        }

        public virtual Tuple<int, List<List<byte>>> SwdSequence(List<Tuple<int, int>> sequences)
        {
            throw new NotImplementedException();
        }

        public virtual void JtagSequence(int cycles, int tms, int readTdo, int tdi)
        {
            throw new NotImplementedException();
        }

        public virtual void Disconnect()
        {
            throw new NotImplementedException();
        }

        public virtual void SetClock(int frequency)
        {
            throw new NotImplementedException();
        }

        public virtual PORT? GetSwjMode()
        {
            throw new NotImplementedException();
        }

        public virtual void Reset()
        {
            throw new NotImplementedException();
        }

        public virtual void AssertReset(bool asserted)
        {
            throw new NotImplementedException();
        }

        public virtual bool IsResetAsserted()
        {
            throw new NotImplementedException();
        }

        public virtual int PinAccess(int mask, int value)
        {
            throw new NotImplementedException();
        }

        public virtual void SetDeferredTransfer(bool enable)
        {
            throw new NotImplementedException();
        }

        public virtual void Flush()
        {
            throw new NotImplementedException();
        }

        public virtual void Verdor(int index, int data)
        {
            throw new NotImplementedException();
        }

        public virtual bool HasSwo
        {
            get { throw new NotImplementedException(); }
        }

        public virtual bool SwoConfigure(bool enabled, uint rate)
        {
            throw new NotImplementedException();
        }

        public virtual bool SwoControl(bool start)
        {
            throw new NotImplementedException();
        }

        public virtual int GetSwoStatus()
        {
            throw new NotImplementedException();
        }

        public virtual int SwoRead(int count)
        {
            throw new NotImplementedException();
        }

        public virtual uint ReadReg(int regId, int dapIndex = 0, bool now = true)
        {
            throw new NotImplementedException();
        }

        public virtual void RegWriteRepeat(int numRepeats, int regId, uint[] dataArray, int dapIndex = 0)
        {
            throw new NotImplementedException();
        }

        public virtual List<uint> RegReadRepeat(int numRepeats, int regId, int dapIndex = 0, bool now = true)
        {
            throw new NotImplementedException();
        }
    }
}
